/*
 * Created by JFormDesigner on Wed Jul 10 17:29:53 EDT 2013
 */

package MaintMenu.PoAnalysis;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import MaintMenu.*;

/**
 * @author Jason Chi
 */
public class Poa extends JFrame {
    int freightCost=6000;
    int cntPerContainer=2500;
    int cntCostbyItem=freightCost/cntPerContainer;
    public Poa() {

        initComponents();
    }

    public int getCntCostbyItem() {
        return cntCostbyItem;
    }

    private void bcActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        System.out.println("Begin POAnalysis BC");
        BCAnalysis bcAnalysis = new BCAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"bc done");
    }

    private void clActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        CLAnalysis bcAnalysis = new CLAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"cl done");
    }

    private void hfActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        HFAnalysis bcAnalysis = new HFAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"hf done");
    }

    private void ltActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        LTAnalysis bcAnalysis = new LTAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"lt done");
    }

    private void mrActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        MRAnalysis bcAnalysis = new MRAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"mr done");
    }

    private void otActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        OTAnalysis bcAnalysis = new OTAnalysis(f, t);
        JOptionPane.showMessageDialog(null,"ot done");
    }

    private void allActionPerformed(ActionEvent e) {
        DateRange dateRange = new DateRange();
        String f = dateRange.threeDayBack();
        
        String t = dateRange.yesterday();
        BCAnalysis bcAnalysis = new BCAnalysis(f, t);
        System.out.println("bc done");
        CLAnalysis clAnalysis = new CLAnalysis(f, t);
        System.out.println("cl done");
        HFAnalysis hfAnalysis = new HFAnalysis(f, t);
        System.out.println("hf done");
        LTAnalysis ltAnalysis = new LTAnalysis(f, t);
        System.out.println("lt done");
        MRAnalysis mrAnalysis = new MRAnalysis(f, t);
        System.out.println("mr done");
        OTAnalysis otAnalysis = new OTAnalysis(f, t);
        System.out.println("ot done");
        JOptionPane.showMessageDialog(null,"All 6 CATs process done");
    }

    private void costCalActionPerformed(ActionEvent e) {

        timerSql timerSql = new timerSql();
        timerSql.setbTime();
        //UPDATE PRICE BY PART#  (This should be by default since all items has DNK part#)

        VendorCostUpd  upd2a  = new VendorCostUpd("HF",1);
        VendorCostUpd  upd1a  = new VendorCostUpd("OT",1);
        VendorCostUpd  upd3a  = new VendorCostUpd("BC",1);
        VendorCostUpd  upd4a  = new VendorCostUpd("CL",1);
        VendorCostUpd  upd5a  = new VendorCostUpd("MR",1);
        VendorCostUpd  upd6a  = new VendorCostUpd("LTLI",1);
        VendorCostUpd  upd7a  = new VendorCostUpd("LTBK",1);


        //UPDATE PRICE BY PL#
//        VendorCostUpd  upd1  = new VendorCostUpd("OT",0);
//        VendorCostUpd  upd2  = new VendorCostUpd("HF",0);
//        VendorCostUpd  upd3  = new VendorCostUpd("BC",0);
//        VendorCostUpd  upd4  = new VendorCostUpd("CL",0);
//        VendorCostUpd  upd5  = new VendorCostUpd("MR",0);
//        VendorCostUpd  upd6  = new VendorCostUpd("LTLI",0);
//        VendorCostUpd  upd7  = new VendorCostUpd("LTBK",0);

        String timeReport = "Process took :"+timerSql.gettTime();
        System.out.println(timeReport);
        JOptionPane.showMessageDialog(null,"Vendor Cost Update for POAnalysis completed ");


    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - jason Chi
        bc = new JButton();
        cl = new JButton();
        hf = new JButton();
        all = new JButton();
        lt = new JButton();
        mr = new JButton();
        ot = new JButton();
        costCal = new JButton();

        //======== this ========
        Container contentPane = getContentPane();
        contentPane.setLayout(new GridBagLayout());
        ((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0};
        ((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
        ((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
        ((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

        //---- bc ----
        bc.setText("BC");
        bc.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                bcActionPerformed(e);
            }
        });
        contentPane.add(bc, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));

        //---- cl ----
        cl.setText("CL");
        cl.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                clActionPerformed(e);
            }
        });
        contentPane.add(cl, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));

        //---- hf ----
        hf.setText("HF");
        hf.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                hfActionPerformed(e);
            }
        });
        contentPane.add(hf, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));

        //---- all ----
        all.setText("ALL 6 CATs");
        all.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                allActionPerformed(e);
            }
        });
        contentPane.add(all, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0), 0, 0));

        //---- lt ----
        lt.setText("LT");
        lt.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ltActionPerformed(e);
            }
        });
        contentPane.add(lt, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));

        //---- mr ----
        mr.setText("MR");
        mr.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                mrActionPerformed(e);
            }
        });
        contentPane.add(mr, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));

        //---- ot ----
        ot.setText("OT");
        ot.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                otActionPerformed(e);
            }
        });
        contentPane.add(ot, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5), 0, 0));

        //---- costCal ----
        costCal.setText("Cost Calc");
        costCal.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                costCalActionPerformed(e);
            }
        });
        contentPane.add(costCal, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - jason Chi
    private JButton bc;
    private JButton cl;
    private JButton hf;
    private JButton all;
    private JButton lt;
    private JButton mr;
    private JButton ot;
    private JButton costCal;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
